import { Module } from '@nestjs/common'

import { APP_GUARD, RouterModule } from '@nestjs/core'

import { AuthModule } from '~/modules/admin/auth/auth.module'

import { JwtAuthGuard } from '~/modules/admin/auth/guards/jwt-auth.guard'
import { RbacGuard } from '~/modules/admin/auth/guards/rbac.guard'
import { CommonModule } from '~/modules/admin/common/common.module'
import { LogModule } from '~/modules/admin/log/log.module'
import { MenuModule } from '~/modules/admin/menu/menu.module'
import { OnlineModule } from '~/modules/admin/online/online.module'
import { RoleModule } from '~/modules/admin/role/role.module'
import { ServeModule } from '~/modules/admin/serve/serve.module'
import { UserModule } from '~/modules/admin/user/user.module'
import { ManageModule } from './manage/manage.module'
import { AppSettingModule } from './setting/app/app.module'
import { StudyModule } from './study/study.module'

const modules = [
  UserModule,
  AuthModule,
  RoleModule,
  MenuModule,
  LogModule,
  OnlineModule,
  ServeModule,
  ManageModule,
  StudyModule,
  CommonModule,
  AppSettingModule,
]

@Module({
  imports: [
    ...modules,
    RouterModule.register([
      {
        path: 'admin',
        module: AdminModule,
        children: [...modules],
      },
    ]),
  ],
  providers: [
    { provide: APP_GUARD, useClass: JwtAuthGuard },
    { provide: APP_GUARD, useClass: RbacGuard },
  ],
  exports: [...modules],
})
export class AdminModule {}
